package mianshi;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author fly
 * @create 2021--04--22--11:00
 */
public class ThreadTest {
    public static void main(String[] args) {
//        Runnable runnable=new MyRunnable();
//        Thread t1=new Thread(runnable);
//        t1.start();
//        System.out.println("xxx");

//        Callable callable=new MyCallable();
//        for(int i=0;i<10;i++){
//            FutureTask task=new FutureTask(callable);
//            new Thread(task,"子线程"+i).start();
//            try {
//                System.out.println("子线程的返回值:"+task.get());
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            } catch (ExecutionException e) {
//                e.printStackTrace();
//            }
//        }

        Thread t2=new MyThread();
        t2.start();
        System.out.println("主线程");

    }


}

class MyRunnable implements Runnable{
    @Override
    public void run() {
        System.out.println("hhh");
    }
}


class MyCallable implements Callable{
    int i=0;
    @Override
    public Object call() throws Exception {
        System.out.println(Thread.currentThread().getName()+" "+i);
        return i++;
    }
}

class MyThread extends Thread{
    @Override
    public void run() {
        super.run();
        System.out.println("fff");
    }
}